package pacificlms.Verifiable.Database;

import pacificlms.Verifiable.*;

/**
 * Copy is a child of VerifiableObject dealing with copies of resources
 * Since all fields are get/set they are not individually commented
 * @author Brian Hume
 */
public class Copy extends VerifiableObject
{
    @Override
    public String TableName() {
        return "Copy";
    }
    
    private String ResourceCode;
    @VerifyAnnotation(ApplicationName="Resource Code", DBName="ResourceCode",  Type=TypeEnum.LOOKUP, Length=50, PrimaryKey=true, LookupDBTable="Resource", LookupDBField="ResourceCode")
    public String ResourceCode(String value)
    {
        return ResourceCode = StandardProcess(ResourceCode, value);
    }
    
    
    private String CopyNumber;
    @VerifyAnnotation(ApplicationName="Copy Number", DBName="CopyNumber",  Type=TypeEnum.NUMERICSTRING, Length=11, PrimaryKey=true)
    public String CopyNumber(String value)
    {
        return CopyNumber = StandardProcess(CopyNumber, value);
    }
    
    
    private String CallNumber;
    @VerifyAnnotation(ApplicationName="Call #", DBName="CallNumber",  Type=TypeEnum.STRING, Length=50)
    public String CallNumber(String value)
    {
        return CallNumber = StandardProcess(CallNumber, value);
    }
    
    
    private String LoanID;
    @VerifyAnnotation(ApplicationName="Loan ID", DBName="LoanID",  Type=TypeEnum.LOOKUP, Length=11, NotNull=false, LookupDBTable="InterLibraryLoan", LookupDBField="LoanID")
    public String LoanID(String value)
    {
        return LoanID = StandardProcess(LoanID, value);
    }
    
    
    private String CopyStatus;
    @VerifyAnnotation(ApplicationName="Copy Status", DBName="CopyStatus",  Type=TypeEnum.ENUM, Length=20, EnumList={"available", "damaged", "lost", "retired"})
    public String CopyStatus(String value)
    {
        return CopyStatus = StandardProcess(CopyStatus, value);
    }
    
    public boolean GoodStatus()
    {
        if (CopyStatus.equalsIgnoreCase("available"))
            return true;
        return false;
    }
    
    @Override
    public String toString()
    {
        return "[" + ResourceCode + "] copy#" + CopyNumber + " : Call #(" + CallNumber + ")";
    }
}
